﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Inventory_AuditingReturn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["ReturnID"]))
        {
            if (!this.IsPostBack)
            {
                Return rtn = Inventory.getReturn(Request["ReturnID"]);
                this.lblReturnId.Text = rtn.ReturnID;
                this.lblStoreName.Text = rtn.StoreName;
                this.TextBox1.Text = rtn.AuditingDescription;
                this.lblStoreID.Text = rtn.StoreID;
                this.lblReturnDate.Text = rtn.ReturnDate.ToString("yyyy-MM-dd");
                if (rtn.IsAccept.HasValue)
                {
                    this.btnAccept.Enabled = false;
                    this.btnReject.Enabled = false;
                }
            }

        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Inventory/ReturnList.aspx");
    }
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(this.lblReturnId.Text.Trim()))
        {
            if (Inventory.AuditingReturn(this.lblStoreID.Text, this.lblReturnId.Text.Trim(), true, TextBox1.Text))
            {
                lblMessage.Text = "退货单处理成功";
                this.btnAccept.Enabled = false;
                this.btnReject.Enabled = false;
            }
            else
                lblMessage.Text = "退货单处理失败";
        }
    }
    protected void btnReject_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(this.lblReturnId.Text.Trim()))
        {
            if (Inventory.AuditingReturn(this.lblStoreID.Text, this.lblReturnId.Text.Trim(), false, TextBox1.Text))
            {
                lblMessage.Text = "退货单处理成功";
                this.btnAccept.Enabled = false;
                this.btnReject.Enabled = false;
            }
            else
                lblMessage.Text = "退货单处理失败";
        }

    }
}
